Namespaces
Namespaces can be used to organize components, to simplify the naming, and to avoid name conflicts. A namespace is recognizable by the double colon at the end, for example: moduleA::signal1, with moduleA as namespace.
To create a namespace, just add a name followed by a double colon to a signal in the Declaration Editor. The same rules for the namespace's name apply as for any other signal, see Edit Declarations. Several namespaces can be added to a single signal, for example, moduleA::submoduleB::signal1. Namespaces are displayed in a light-brown color.
The syntax of a namespace is as follows:
namespace:expression | ← | a1:expression :: a2:expression :: c1:expression |
Namespaces can be used in step lists, assesslets, and functions. Note that there is no space between the two colons.
You can either refer to a signal by its fully qualified name, thus with the namespace, for example, piketec::component2::pressure, or use the short name, thus pressure. In order to use the short name, write the namespace into the Using namespaces field. Several namespaces must be separated by a comma. The autocompletion feature (shortcut Ctrl+Space) can be used to insert the names. They can also be copied from the Declaration Editor (shortcut Ctrl+ ALT+C), see Declaration Editor.
If a signal has hierarchical namespaces, like in piketec::component2::pressure
, you could also write the first namespace, piketec
, in the Using namespaces field. You then have to address the signal by component2::pressure
.
When you enter a namespace in the Using namespaces field, the short name of the signal might be identical with another signal name. To avoid ambiguity, use the fully qualified signal name including the namespaces instead of the short one. If you want to address a namespaceless signal with the same name, add a double colon in front of it. This namespaceless double colon is interpreted by TPT as "this signal has no namespace".
Refactor namespaces
You can alter a namespace in the Declaration Editor. The namespace will automatically be adapted at nearly all places it is used in your project.
The refactoring of signal names has no effect on the Dashboard script, comments or strings.
Expand the hierarchical folder structure
Signals with namespaces specified in the Declaration Editor or displayed in the Signal Viewer are arranged in a hierarchical folder structure. The folders can be expanded or collapsed.
Reduce the number of sub-namespaces
The number of sub-namespaces used in the hierarchical folder structure can be reduced in the Declaration Editor , for example, to shorten the signal name length.
Select View|Declaration Editor to open the Declaration Editor. Click Show signals in namespaces hierarchically to unfold the signal name and its namespaces.
Delete one sub-namespace displayed in the hierarchy, for example, Model_Root. Select another line in the table and click OK in the message box that appears. The remaining sub-namespaces are integrated in the parent namespace structure.
The length of the signal name was shortened in this way.